from flask import request, make_response
from admin import admin_power
from admin import admin_stations
from utils import utils

class AdminController:
    @staticmethod
    def admin_url(app):
        # station power setting
        @app.route("/api/admin/power_set", methods=['POST'])
        def admin_power_set():
            power_return = admin_power.AdminPower.update_power_state()
            utils.print_charge_queue()
            utils.print_wait_queue()
            return power_return

        # get all stations status
        @app.route("/api/admin/stations_list", methods=['GET'])
        def admin_stations_list():
            stations_list_res = admin_stations.AdminStations.get_station_list()
            return stations_list_res

        # get specified station charging queue
        @app.route("/api/admin/charge_queue", methods=['GET'])
        def admin_charge_queue():
            charge_queue_res = admin_stations.AdminStations.get_station_query()
            return charge_queue_res

        @app.route("/api/admin/reports_list", methods=['GET'])
        def admin_report_list():
            report_list_res = admin_stations.AdminStations.get_report_list()
            return report_list_res

        # staion fault and recovery
        @app.route("/api/admin/station_failure", methods=['POST'])
        def admin_station_fault():
            station_res = admin_power.AdminPower.station_failure()
            utils.print_charge_queue()
            utils.print_wait_queue()
            return station_res

        @app.route("/api/admin/station_recovery", methods=['POST'])
        def admin_station_recovery():
            station_res = admin_power.AdminPower.station_recovery()
            utils.print_charge_queue()
            utils.print_wait_queue()
            return station_res
